# configure and define compiler stuff here.

function(GConfigureCompiler)
	
	#Absoft = Absoft Fortran (absoft.com)
	#ADSP = Analog VisualDSP++ (analog.com)
	#AppleClang = Apple Clang (apple.com)
	#Clang = LLVM Clang (clang.llvm.org)
	#Cray = Cray Compiler (cray.com)
	#Embarcadero, Borland = Embarcadero (embarcadero.com)
	#G95 = G95 Fortran (g95.org)
	#GNU = GNU Compiler Collection (gcc.gnu.org)
	#HP = Hewlett-Packard Compiler (hp.com)
	#Intel = Intel Compiler (intel.com)
	#MIPSpro = SGI MIPSpro (sgi.com)
	#MSVC = Microsoft Visual Studio (microsoft.com)
	#PGI = The Portland Group (pgroup.com)
	#PathScale = PathScale (pathscale.com)
	#SDCC = Small Device C Compiler (sdcc.sourceforge.net)
	#SunPro = Oracle Solaris Studio (oracle.com)
	#TI = Texas Instruments (ti.com)
	#TinyCC = Tiny C Compiler (tinycc.org)
	#Watcom = Open Watcom (openwatcom.org)
	#XL, VisualAge, zOS = IBM XL (ibm.com)
	
	IF (${CMAKE_CXX_COMPILER_ID} EQUAL "Absoft")
		SET(G_HOST_COMPILER "Absoft" CACHE INTERNAL "")
		SET(G_HOST_COMPILER_ABSOFT TRUE)
	ELSEIF (${CMAKE_CXX_COMPILER_ID} EQUAL "ADSP")
		SET(G_HOST_COMPILER "Adsp" CACHE INTERNAL "")
		SET(G_HOST_COMPILER_ADSP TRUE)
	ELSEIF (${CMAKE_CXX_COMPILER_ID} EQUAL "AppleClang")
		SET(G_HOST_COMPILER "AppleClang" CACHE INTERNAL "")
		SET(G_HOST_COMPILER_APPLECLANG TRUE)
	ELSEIF (${CMAKE_CXX_COMPILER_ID} EQUAL "Clang")
		SET(G_HOST_COMPILER "Clang" CACHE INTERNAL "")
		SET(G_HOST_COMPILER_CLANG TRUE)
	ELSEIF (${CMAKE_CXX_COMPILER_ID} EQUAL "Cray")
		SET(G_HOST_COMPILER "Cray" CACHE INTERNAL "")
		SET(G_HOST_COMPILER_CRAY TRUE)
	ELSEIF (${CMAKE_CXX_COMPILER_ID} EQUAL "Embarcadero")
		SET(G_HOST_COMPILER "Borland" CACHE INTERNAL "")
		SET(G_HOST_COMPILER_BORLAND TRUE)
	ELSEIF (${CMAKE_CXX_COMPILER_ID} EQUAL "Borland")
		SET(G_HOST_COMPILER "Borland" CACHE INTERNAL "")
		SET(G_HOST_COMPILER_BORLAND TRUE)
	ELSEIF (${CMAKE_CXX_COMPILER_ID} EQUAL "G95")
		SET(G_HOST_COMPILER "g95" CACHE INTERNAL "")
		SET(G_HOST_COMPILER_G95 TRUE)
	ELSEIF (${CMAKE_CXX_COMPILER_ID} EQUAL "GNU")
		SET(G_HOST_COMPILER "Gcc" CACHE INTERNAL "")
		SET(G_HOST_COMPILER_GCC TRUE)
	ELSEIF (${CMAKE_CXX_COMPILER_ID} EQUAL "HP")
		SET(G_HOST_COMPILER "Hp" CACHE INTERNAL "")
		SET(G_HOST_COMPILER_HP TRUE)
	ELSEIF (${CMAKE_CXX_COMPILER_ID} EQUAL "Intel")
		SET(G_HOST_COMPILER "Intel" CACHE INTERNAL "")
		SET(G_HOST_COMPILER_INTEL TRUE)
	ELSEIF (${CMAKE_CXX_COMPILER_ID} EQUAL "MIPSpro")
		SET(G_HOST_COMPILER "MipsPro" CACHE INTERNAL "")
		SET(G_HOST_COMPILER_MIPSPRO TRUE)
	ELSEIF (${CMAKE_CXX_COMPILER_ID} EQUAL "MSVC")
		SET(G_HOST_COMPILER "Msvc" CACHE INTERNAL "")
		SET(G_HOST_COMPILER_MSVC TRUE)
	ELSEIF (${CMAKE_CXX_COMPILER_ID} EQUAL "PGI")
		SET(G_HOST_COMPILER "Pgi" CACHE INTERNAL "")
		SET(G_HOST_COMPILER_PGI TRUE)
	ELSEIF (${CMAKE_CXX_COMPILER_ID} EQUAL "PathScale")
		SET(G_HOST_COMPILER "PathScale" CACHE INTERNAL "")
		SET(G_HOST_COMPILER_PATHSCALE TRUE)
	ELSEIF (${CMAKE_CXX_COMPILER_ID} EQUAL "SDCC")
		SET(G_HOST_COMPILER "Sdcc" CACHE INTERNAL "")
		SET(G_HOST_COMPILER_SDCC TRUE)
	ELSEIF (${CMAKE_CXX_COMPILER_ID} EQUAL "SunPro")
		SET(G_HOST_COMPILER "SunPro" CACHE INTERNAL "")
		SET(G_HOST_COMPILER_SUNPRO TRUE)
	ELSEIF (${CMAKE_CXX_COMPILER_ID} EQUAL "TI")
		SET(G_HOST_COMPILER "Ti" CACHE INTERNAL "")
		SET(G_HOST_COMPILER_TI TRUE)
	ELSEIF (${CMAKE_CXX_COMPILER_ID} EQUAL "TinyCC")
		SET(G_HOST_COMPILER "TinyCC" CACHE INTERNAL "")
		SET(G_HOST_COMPILER_TINYCC TRUE)
	ELSEIF (${CMAKE_CXX_COMPILER_ID} EQUAL "Watcom")
		SET(G_HOST_COMPILER "Watcom" CACHE INTERNAL "")
		SET(G_HOST_COMPILER_WATCOM TRUE)
	ELSEIF (${CMAKE_CXX_COMPILER_ID} EQUAL "XL")
		SET(G_HOST_COMPILER "Ibm" CACHE INTERNAL "")
		SET(G_HOST_COMPILER_IBM TRUE)
	ELSEIF (${CMAKE_CXX_COMPILER_ID} EQUAL "VisualAge")
		SET(G_HOST_COMPILER "Ibm" CACHE INTERNAL "")
		SET(G_HOST_COMPILER_IBM TRUE)
	ELSEIF (${CMAKE_CXX_COMPILER_ID} EQUAL "zOS")
		SET(G_HOST_COMPILER "Ibm" CACHE INTERNAL "")
		SET(G_HOST_COMPILER_IBM TRUE)
	ELSE ()
		MESSAGE(FATAL_ERROR "Unknown compiler.")
	ENDIF ()

	SET(G_HOST_COMPILER_VER ${CMAKE_CXX_COMPILER_VERSION} CACHE INTERNAL "")
	
	
	 # "myDefs=\"${flag}\";FC_CACHEDIR=\"${FC_CACHEDIR}\";FONTCONFIG_PATH=\"${FONTCONFIG_PATH}\"
	
	# define compiler preprocessors
	STRING(TOUPPER ${G_HOST_COMPILER} COMPILER_NAME_UPPER)
	ADD_DEFINITIONS(-DG_COMPILER_${COMPILER_NAME_UPPER})
	ADD_DEFINITIONS(-DG_COMPILER="${G_HOST_COMPILER}")
	
	ADD_DEFINITIONS(-DG_COMPILER_VERSION="${G_HOST_COMPILER_VER}")
	
endfunction()